package com.xuelang.pipeline.client.pipeline.enums;

import lombok.Getter;

/**
 * <p>触发方式枚举类</p>
 *
 * @author : yixin.lys
 * @date : 2024-06-12 10:17
 **/
@Getter
public enum TriggerWayEnum {

    PERIOD(1, "周期定时触发"),
    ONCE(2, "单次定时触发"),
    MANUAL(3, "手动触发"),
    EVENT(4, "事件触发");

    private final Integer value;
    private final String desc;

    TriggerWayEnum(Integer value, String desc){
        this.value = value;
        this.desc = desc;
    }

    // 通过值获取对应的枚举类型
    public static TriggerWayEnum fromValue(Integer value) {
        for (TriggerWayEnum way : TriggerWayEnum.values()) {
            if (way.getValue().equals(value)) {
                return way;
            }
        }
        throw new IllegalArgumentException("Unknown value: " + value);
    }

}
